package com.csair.common;

import android.app.Application;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Build;
import android.support.multidex.MultiDex;
import android.support.multidex.MultiDexApplication;
import android.webkit.WebView;

import com.csair.common.utils.LanguageUtil;
import com.csair.common.utils.LogUtils;


/**
 * @author vaycent (vaycentsun@gmail.com)
 * @date 2018/6/6
 */

public abstract class CommonApplication extends MultiDexApplication {

    private static CommonApplication mCommonApplication;

    public CommonApplication() {
        LogUtils.i("CommonApplication","CommonApplication");
        mCommonApplication = this;
    }

    @Override
    protected void attachBaseContext(Context newBase) {
        Context context = LanguageUtil.refreshContext(newBase);
        super.attachBaseContext(context);
        MultiDex.install(context);
        LogUtils.i("CommonApplication","attachBaseContext");
    }

    @Override
    public void onCreate() {
        super.onCreate();
        LogUtils.i("CommonApplication","onCreate");
        /**
         * android 7.0后，切换中英文，访问webview出来，语言错误问题
         */
        if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.N){
            new WebView(this).destroy();
        }
        /********************/
    }
    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        LogUtils.i("CommonApplication","onConfigurationChanged");
    }
    @Override
    public void onTrimMemory(int level) {
        super.onTrimMemory(level);
        LogUtils.i("CommonApplication","onTrimMemory:"+level);
    }











    public static Application getApplication() {
        return mCommonApplication;
    }








}
